There isn't really a meaningful difference; either way the immune system is responding to a protein and "remembering" it.
mRNA breaks down within a few days, by which point spike protein production by your cells has stopped, and the spike proteins themselves break down within a few weeks.
Inactivated virus would be broken down and excreted within a similar timeframe or faster; it's the immune system memory of the proteins that it encountered that persists.
Your body only briefly produced spike protein after vaccination. The lasting immunity isn't caused by ongoing spike protein production.