When the top of your foot hurts the pain on the top of your foot can be caused by Extensor tendonitis or overuse or injury.
Sometimes when you wear tight fitting shoes the tight fitting shoes can compress the nerves in the top of your foot which can lead to foot pain on the top of your feet.
Other causes are overuse of the foot muscles and bones from running, jogging, walking too far etc.
The most common causes of pain on the top of your feet are poorly fitting shoes, prolonged period on feet, overuse such as long walks or running a marathon, sprains, strains, or trauma.
Some diseases such as diabetes can cause pain on the bottom of your foot and sometimes on the top of your foot and in your toes.
But if the pain goes away and does not come back then it's likely just because of overuse or tendonitis.