There are three types of Master Materia: Magic, Command, and Summon. To gain a Master Materia, first you have to master at least one of each materia in a one of the categories (Magic, Command, or Summon). Once you have all of them mastered, you can trade them all to the corresponding Huge Materia in Bugenhagen's house for the Master Materia. That's assuming you've recovered the Huge Materia throughout the game. You have to do this again for each Master Materia you want.

A Master Materia enables the use of all the abilities from all materia of a certain category traded to the Huge Materia by equipping just one piece of materia.