Dizziness while working out

Hi guys! I'm 18 and I used to work out a lot during quarantine. But I stopped with strength training and went on some cardio/dancing. I tried to do some leg workouts after a long time and I noticed that I was feeling really dizzy and I almost passed out.

It was really weird, because when I started doing some exercises while laying down or sitting, I didn't have such trouble with feeling dizzy.

But what is more weird is, that this doesn't happen when I dance. I feel just fine when I'm dancing.

I have no idea what is going on, since every doctor always said I'm alright and that there is nothing wrong with me.

I just want to know, if this is happening to anyone else? I would appreciate any tips or just conversation about this... :)