Using ">" does not work with "sed" but ">>" does?

I had created a text file called states.txt with a list of states as such:

New York
Flordia
Mississippi
New york

and used:

sed “s/york/York City/g” states.txt

to replace “New york” with “New York City”. I tried to take that output and overwrite states.txt with

sed ‘s/york/York City/g’ states.txt | cat > states.txt

but all I get back is an empty states.txt file.
However, when I try to concatenate it with

sed ‘s/york/York City/g’ states.txt | cat >> states.txt

this seems to work, but I would rather overwrite the original list.
Why does “>” not work in this situation?

sed works fine with >, that’s not the problem

when reading and writing to the same resource you need to pay some extra attention to the order that things happen (or better yet, not rely on it happening in any specific order to reduce the chance of there being a mistake)

and, redundant use of cat, its output is the same as the previous program, you may as well insert cat ten or twenty times there

Sorry, not following your explanation. I’ve tried removing cat and it doesn’t work. I thought | would pipe the output to the command on the right.