Why is my ankle swelling if I got hit in the shin?

Gravity. You may have had some internal bleeding/bruising or inflammation. This fluid will obey gravity and flow down.
Injury to a tendon. Not usual but you could have injuried a tendon that causes you to walk differently causing a strain around the ankle.