How can I write a book about paper writing which contains real examples without violating copyright?
The best solution would be to get permission from each copyright holder for each paper/snippet you use. This is often seen in books ie a list of figures and a statement of permission from each author X and Y and Z.

Using the material may be ok at the moment because it is for an educational purpose, but to put that into a book is probably going to be more a business/profit purpose which is different for copyright...

But I get the impression that you don’t want to do this as you mention “I have hundreds....”

You will need to check this properly with a copyright lawyer / legal team...