Why is inverting the selection selecting all vertices?
You might have double vertices. What might have happened is that the vertices that were selected were double ones, so inverting the selection also selected the vertices that were being overlapped by them. This would give the illusion that all vertices are selected.

To remove double vertices, in Edit Mode go to Mesh &gt; Clean Up &gt; Merge By Distance. Any detected double vertices will be removed and a message will show up saying how many double vertices were detected and removed. If no double vertices were removed. this might be a bug.