It's a Wonderful Life tells us a story about what it means to be a librarian. In this alternate reality, Mary is portrayed as a librarian in order to convey just how bad things got without George around. Mary is an old maid, and in 1946, "old maid" was synonymous with "librarian".
This character certainly reflects societal beliefs about librarians in 1946: that librarians were single, unhappy women. Librarian identity in film has become a bit more complex since then, but Mary's character is still all too familiar.