A swap file competes for space with other files on the filesystem. If the filesystem is full, then a dynamically sized swap file wouldn’t be able to grow as intended.
Also, a swap filesystem can be mounted and usable without any of the other filesystems being initialized. If your swap was on a regular filesystem that got corrupted, on top of the problem of a corrupted filesystem, you’d have the additional problem of having to fix the swap problem.
Many aeons ago I was developing the virtual memory system for a proprietary operating system (Penpoint, if you remember Go Corp.) The architecture was different than the monolithic kernels typical in that era, and the filesystem was partially a user process. We were running into some hard-to-debug deadlocks. I finally discovered what was happening was part of the filesystem was being swapped out to the swap file, and the VM system was trying to swap it back in by calling the filesystem to read the file … That’s what we technically call a “not good” situation.
I think I read just this week that that Linus Torvalds marked the latest 5.12-rc1 linux kernel as DONTUSE due to a bug in the swap file handler that lost the current file offset, and started writing new swap data into the rest of the file system