1. Mainly through any kind of transformations. Each time a transformatio happens through a tf item, random event or trap you gain +2 Mastery points for that transformation. Winning a run gives 10 tf mastery for every unlocked transformation.
Things like modifications and some artefacts can increase this basic values. For exsample if you had three modifications on that all give +1 tf mastery each, every tf mastery gain would be +5 instead then.
2. Forges and altar does not count. Only the shop, lottery and the traveling merchants from random events count.
Hope this helps^^