I attempted an explanation of how L2 orbit works over at https://libranet.de/display/0b6b25a8-1861-f16a-5504-65e089452108 but I'll repeat it in brief.

You can orbit L2 because Earth pulls you. The Y component of the pull keeps you in orbit around L2 and the X component cancels out with your centrifugal force from orbiting the Sun "too fast".

There is also a proper and deeper explanation:

Launch Pad Astronomy: How James Webb Orbits 'Nothing'

https://farside.link/invidious/watch?v=ybn8-_QV8Tg

https://www.youtube.com/watch?v=ybn8-_QV8Tg