I am a very big fan of celtic music and i often listen to them for hours straight. But how did these music evolve, like what are the main occasion for these musics, what purpose these music served etc. It would be very much helpful if explained.
The history of the various peoples known as "Celts" is long and scholars are not in total agreement about all of it. Today the nations known as 'Celtic' have a living Celtic language spoken in some of that nation's territory (Wales, Scotland, Ireland , Brittany, Cornwall, Isle of Man) or a recent Celtic heritage but no surviving language (Galicia and other parts of the Iberian peninsula). Some places have their own variant Celtic heritage via emigration, for example Gaelic in Cape Breton or Welsh in Patagonia.
Festivals such as Glasgow's "Celtic Connections" are a showcase for music derived from the Celtic traditions of various places.
The music has instruments in common - fiddle, harp, whistles, bagpipes, and many common experiences - exile, oppression and attachment to their (now distant) homeland. The music itself was part of the original culture, or a later revival, as part of a Celtic nationalism, and also something to hang on to in exile.
My answer only scratches the surface of your (broad) question but I hope it gives some ideas for you and others to explore what Celtic heritage is about. (Thanks to Wikipedia for some content above- you may want to explore some of the content there as deeper background for the question)
There is a very nice presentation from Prof. Fergus Kelly on Early Irish Music online here : https://www.youtube.com/watch?v=lTme66NdTpc
It's pretty comprehensive; also I'd sugest to print out the notes before as he keeps referencing them throughout the talk.