You're probably thinking of either the method called paradoxical intention or the advice to get out of bed if you can't fall asleep for more than 10-15 minutes. It sounds counterintuitive - why get up when you want to sleep? - but the logic is this: if you're lying there panicking that you won't fall asleep, it only ramps up the tension and anxiety, which makes it even harder to drift off. By getting up, you break that vicious cycle, do something calm in another room (read, draw, something boring), and when you're actually tired again, you go back to bed.
Another popular method is the 4-7-8 technique, where you breathe in a specific rhythm: inhale for 4 counts, hold for 7, exhale for 8. It works because the longer exhale activates your parasympathetic nervous system, which is responsible for relaxation. It's not magic or anything - just physiology.
Doctors actually do recommend these methods because they don't involve medication and they work by redirecting your attention or calming your body down on a biological level. The key thing is not to torture yourself in bed waiting for sleep to come, because that only strengthens the connection between your bed and anxiety. Pick whichever approach makes more sense to you.