The figures you get by combining two s.h.m. with different phase and frequency are called Lissajous figures.
Basically the answer is in the Wikipedia article (and the other very good answers here), but maybe I'll expand a bit on this gif:
https://upload.wikimedia.org/wikipedia/commons/3/38/Circular_Lissajous.gif
In principle you can also get the circle like this way: say you have two masses, each attached to a spring. Neglecting friction, the motions the two masses make are simple harmonic motions. Now you mount the springs perpendicular to each other and draw parallels from one mass to the y-axis and from the second to the x-axis.
You would get the phase difference of $\pi/2$ for example by starting the first spring at half and the second spring at zero distance from the point the spring is mounted, assuming the maximum distance i.e. the amplitude for them is the same.
Every time this lines meet, you draw a point. At the end, it looks like this:

So in the end, the combination of two shm with phase difference $\pi/2$ and same amplitude gives you a circle. When you have zero phase difference - this means you start the two masses at the same point - you get a figure like this:
https://upload.wikimedia.org/wikipedia/commons/e/ed/Lissajous_1_1_0.svg