The maths is complex but plenty of references can be found on the www. And yes you do need degree level maths (which is why I cannot explain it even if I wanted to - I did maths at univ. but wasn't any good at it).
GPS works out heading and velocity using a different part of the position fixing algorithm, and it gets track and velocity calculated very accurately even if the position is not that accurately known.
As mentioned, there are GPSs which contain a conventional compass, either a traditional floating type one, or a solid state one. You can get wrist watches with such compasses in them - Tissot do one for example.
The confusion between HDG and TRK is probably just poor PPL training but the wider issue is the anal attitude towards GPS for so many years.
As an example or poor training, I have met so many pilots who think that the plane handles differently when flying with a tailwind v. headwind, etc.