Basically you Hidden Power type is determined by what IV spread you have. IVs or Individual Values are a hidden part to Pokemon that you cant just look up on you Pokemon's summary page. To find them you will either have to do a lot of math or just use a IV calculator. To quote our IV Page here at the DB:
Individual Values (IVs for short) are the key to determining your Pokemon's stats. IVs are randomly assigned when you encounter any wild Pokemon (or receive it as a gift or egg). They consist of six numbers corresponding to HP, Attack, Defense, Special Attack, Special Defense and Speed. Each range from 0-31 and the higher the number, the better your Pokemon's stat will be.
This means that each stat has its own IV number. So you may have 31 Ivs in Hit Points but you might also have 0 Ivs in Speed at the same time. The IVs are determined and set in stone(which means you cant change the without hacking your game) when you first encounter said Pokemon weather you caught it in the wild, hatched it from a egg, or any other method used to legally get a Pokemon. Ivs determine your hidden power based on the spread so you need a certain number in each stat to get the exact hidden power you want and if you dont have them you have to keep catching/trading/hatching for a new Pokemon to get them to change. This process can take forever to do however thats why most people just choose to use Pokegen where the can hack but not hack a Pokemon into their games that have the desire IV spread they want. You can use This as a way to figure out what IVs you have for each stat.