Do universities keep work done by students for later research and/or plagiarism detection by future students (eg. self-plagiarism)?
The rules of different institutions vary, so there's no one-size-fits-all answer here. However, plagiarism detection software like Turnitin does store copies of papers indefinitely:
Our database contains 58 billion web pages, 570 million student papers and 150 million articles from academic books and publications.
They also store archived web pages no longer available on the Internet. Other plagiarism software likely works in a similar fashion.