Every library system is different. Some do not want former residents to continue to check out books.
Others, only grant membership to residents, but once you are a member, you are a member for life (even if you move).
Point is: if you are concerned about whether it is moral or not, simply call your library and ask. If they say you need to turn in (or cut up) your library card, then do it. If they say you can continue to use it, then use it.
BTW - many library systems in the United States today are receiving a large percentage of their funding from the County or State govts. Yes, the local govt might have founded the library & continues to give them some funding, but in many areas today, the Counties & States are providing far more funding since libraries are expensive to run. Also, many town libraries have also created “library cooperation groups” where you are a member at all the libraries in the group.
Point is, call your library, see what they say, and do whatever they tell you.
God Bless