Do National Insurance contributions count as proof of the time someone has been in the UK? How can I use it to prove my residence?

Yes, if you were consistently working, your National Insurance Contributions record will show that, unless you were a posted worker. 

You can request your records for free from HMRC here:

Your DWP records can equally show presence in the UK. These records can also be requested for free, here:

Please also refer to the Young Europeans guide on demystifying citizenship, which has a list of other requests for information you can make to prove your continuous residence.