What's the best way to sleep (position, mattress, etc.), as a lifelong habit, so not to get sleep problems 30 years later?

Long answer! Best way to sleep can be very personalized. In general I would say make sure you are correct/near ideal body weight, avoid sedative hypnotics prior to sleep, sleep on side if comfortable, avoid matresses that may become old and worn, avoid allergens during sleep (make sure breathing clean air).
Sleep position. Sleeping on your stomach usually requires you to have your head turned to the side for hours ; makes it difficult to keep the spine in a neutral position. It also puts pressure on joints ; muscles. Sleeping on your back can aid the head ; spine to maintain a neutral position. The next best is sleeping on the side. Invest in a good mattress!