How did Mahayan, Hinayan,Vajrayana come into Buddhism? How many types of sects like Mahayans, Hinayans,Vajrayana are there in Buddhism? How did they come into Buddhism? To my knowledge Buddha never talked about any sort of 'yans'.

Who created these 'Yans'? What was the necessity of creating these 'Yans'?
The Buddha lived 2500 or more years ago. That is relevant: humanity has had 2500 years to think about his teachings and disagree about them. Or more kindly put: in trying to live by his teachings, people have thought about them and come at different interpretations. 

The main schools are - as you note:

Theravada - the only living 'hinayana' school. It preserved the Pali canon and as the only living representation of early Buddhism, many people consider it the most 'pure' school. However - it is still only one out of about two dozen schools that existed around the time of Christ. 


  Mahayana is usually translated as'great vehicle', in opposition to Hinayana 'small vehicle'. This translation is obviously derogatory and offensive to the only early Buddhist school still in existence: Theravada Buddhism. Mahayana can actually also be translated as 'great path', that is: a path for every being. Hinayana would then mean: small path, or path only for monks actively striving to become arhats. source


Mahayana - everything else, including Vajrayana. Mahayana started in India around the time of Christ - not in China as one answer here suggests. It is true though that Chinese and Japanese Buddhism are dominated by the Mahayana approach.
It could be said that the Mahayana approach came about through the need for a more explicit compassion in Buddhist teaching and practice. The Bodhisattva ideal filled that hole. 
The Bodhisattva ideal: 


  May I attain Buddhahood for the benefit of all sentient beings.


Mahayana Buddhism includes Zen as well as Tibetan Buddhism. 

Vajrayana is a form of Mahayana Buddhism, but it takes individual Buddhas as their main object of meditation. One theory about why it became popular is that it is a practice that helps a lot in times of uncertainty. It became the main form of Indian Buddhism in the centuries before Islam came to India - it was a time when Hinduism became prominent again and Buddhists were on the defensive. 

Do note that it is difficult to be sure about the history of Vajrayana, because its practitioners are traditionally vowed to secrecy about their practice.

Vajrayana is prominent in Tibetan Buddhism, but it also survives in Japanese Buddhist ritual.