Affinity is basically XP in other games.
Killing enemies, doing whatever in-game = you get XP
You get enough XP for a weapon / frame => said weapon / frame ranks up
Weapon / frame rank up = Mastery Rank Points
Affinity =/= Mastery Rank points
They are not the same.
Once those MR points are earned, they're there to stay.
Affinity is what you earn to level up or rank up your stuff.
MR points is what you earn once you actually get that rank on your stuff.
As for respawning, it uses the XP you earned in that mission. Read this for more detailed info, as I don't know it off the top of my head: https://warframe.fandom.com/wiki/Death