Hyperpigmentation or dark skin spots can happen at anytime in your life. Most are caused from skin damage from things like the sun, past acne or other skin problems. Another cause is hormonal changes. Acting early to prevent skin damage is one thing you can do to avoid dark spots, but you can't avoid hormones.
Using a product that works directly on the spot to repair the area is effective but using products to protect the skin will help minimize the problem to begin with.