Lord Hanuman was able to fly from birth, which is a gift given by his father Vayu Deva. You can notice this point when he first was tempted to eat the sun and flew to it.
But as he grew up, (as all kids do) he started to enjoy his childhood by troubling other saints, rushi (muni) with his extreme powers. So just to stay safe, rushis gave him Shaap to forget all his powers. Since Lord Hanuman was born for a reason, if he forgot all his powers, then the reason for which he was born would not be fulfilled. So as an alternate for that Shaap, rushis also said that in time of need, if someone reminded him that he has powers, he will get his powers back.
I have also heard that lord Hanuman was actually not able to fly but to jump to higher distances. Is it true?
This fly/jump is a knowledge which is given by his father Vayu Deva. When he was kid, he made his first fly/jump.
Apart from Hanuman, all Vanaras were able to fly. But they have their own capacity or limits to reach. At the time of flying to Lanka, Hanuman was not considered as first priority. Sugreeva asked others first like, Angada, Jambavanta and so on, but all others weren't able to fly that far.
Jambavanta considered to be elder among all have strength to fly for any distance, because he is old and less strength, he willingly suggested Hanuman to fly that far. Another reason may be because of Hanumans's birth reason, he is born to serve Lord Rama. So any work that belongs to Rama, Hanuman will do it.
Flying of Hanuman is also illustrated in one more situation. After the victory of Rama, (some part I excluded here) Rama gave a white lotus flower to Hanuman and told him to give it to Surya Deva on behalf of Rama. Hanuman flew to Surya Loka and gave that flower to Surya Deva. In this case, there is no Yojanas count, because he flew in outer space restlessly.