I have only bought adept magic of farengar and other court wizards and i would like to know how to get the expert and master spells of every magic school.
You have to progress your skill level to the point of being able to use those types of spells. While Expert maybe be available just in that manner, Master level spells require you to reach 100 in your skill and complete a quest from the people of the appropriate branch of magic form the Mage College at Winterhold.
You need to be level 65 in a skill to buy the related expert tomes. You should seek out the teacher at the College of Winterhold who specializes in the skill( Experts Colette Marence in Restoration and Phinis Gestor in Conjuration, Masters Faralda in Destruction, Drevis Neloren in Illusion, and Tolfdir in Alteration). The first 4 can easily be found sleeping in the hall of countenance at 3AM, while Tolfdir is usually in the hall of attainment. If he isn't there, he's likely at Saarthal(if that's the case, you should have a quest in your journal you can activate for a quest marker. It isn't all that far from Winterhold).
You need to be level 90 in a skill to start the quest to make the master spells available for that school(1 or 2 schools are bugged so you have to be 100 in the skill before starting the related quest). You talk to the same 5 people depending on the school in which you want to learn master spells. You always get one spell for free on completing the quest, with 1 or more additional spells available for sale afterward. In the case of destruction spells, you get a book with a clue about finding a location. When you get there you will find an object on which to put the book. You need to cast the proper element on the object to continue(use novice spells to avoid glitches). Pick up the book and read it again for another clue about another location and another element. You will do this a total of 3 times(1 for each element). When you read the book after the last element, you will automatically learn the Firestorm spell and can go back to the college to purchase Blizzard and and Lightning Storm if you want.
Firestorm is quite potent at lower difficulty levels versus vampires and draugr deathlords but much less so on higher difficulty. I suggest using a word of become etherial before casting as all master spells take a few seconds and you will be interrupted if you take a decent hit. Blizzard's damage is affected by your own magic resistance and frost resistance. If these are very high, the spell will do little to no damage. Still fun to walk in to a place like Breezehome and set it off. Stuff will fly everywhere. When you get bored, reload the autosave so you don't have to pick up the mess. Lightning storm is capable of disintegrating a low health target, even without that perk in Destruction. I like to use it for engaging those dragons that circle at a distance and won't attack unless you get a hit in(this spell has a longer range than other shock spells and like them is an instant hit).
The restoration ritual can be completed with just a high sneak skill, but you should leave most of your stuff in a safe container before doing it. Neither of the spells are that great, imo. The objects you need for the Illusion ritual can be tough to locate, but you can google where to find them as they're in fixed spots. You get the Hysteria tome, but I sell it to buy the Call to Arms tome for the Civil War quest line. You can also buy Mayhem and Harmony. The latter can be amazing for leveling the skill again if you happen to make it legendary. I suggest you do the Conjuration ritual as soon as you feel your character is pretty strong, as you opponent for that one has no level cap and levels with you. It can be very dangerous if you can't take it down fast. You get flame thrall with the ability to purchase dead thrall, frost thrall and storm thrall. The first 2 of those can be useful but the storm thrall is bugged and has no better stats than a storm atronach or potent storm atronach. The Alteration ritual will have you hunt down a specific item in a random location needed to extract something from a dragon. Return that something to Tolfdir for the Dragonhide tome. You can then buy Mass Paralysis which can be lots of fun.If you hang on to the "extractor" you can get additional "stuff" to sell to merchants for extra cash.