Maintaining a swimming pool is an expense that many schools, especially in poorer districts can’t afford.
German here: the solution for most of the schools I went to and heard of (elementary) was to get a bus to drive to the next public swimming pool and they’d let us use it for a few hours. The government is funding that. And that solution worked for most of them, although I only managed to get do my swim test after swimming classes in school because I was anxious about it.