Which button I have to press to scan a planet? Is it automatic? Do I have to fly towards it? If I pass 500 LS from every celestial body is it enough?
In supercruise, holding the secondary fire button should activate your scanner. Once the bar is charged, the scanner will pulse nearby space, revealing any celestial bodies close enough. The discovery scanner you start with only has a range of 500 ls, more expensive scanners have larger ranges.
For larger systems you can still find bodies outside of initial range of your scanner. My usual method is to fly at full speed away from the star and look carefully for objects on the star field that move differently relative to the background stars (easiest when looking out of a window). Fly towards those while continually firing your scanner to discover them. You can see someone demonstrating this here at about 15mins.
Just performing this activity will earn you some money but to make more, you'll also need to perform more detailed scans of the bodies you find too.
Target an unknown body you have found and approach it in supercruise. Once you get close enough, you should see a HUD element telling you that you are scanning that celestial. Performing these mode detailed scans will earn you more money (and even more if you have a surface scanner installed).
It's not worth performing detailed scans of asteroid mining sites but everything else will earn credits as indicated below: