What is the difference between 猫を買うことにしました 猫を買いました

What is the difference between
猫を買うことにしました
猫を買いました

noun + ni suru (or i-adjective + ku suru) means something along the lines of “decide”, “go with” (as when decided what to order), or more generally “make it so that X happens…”/“Cause something to happen/change”.
For use with a verb you add “koto” after the verb (so-called “nominalization” of the verb).
In this case “Neko o kaimashita” means “I had a cat”
“Neko o kau koto ni shimashita” means “I decided to have a cat”

[Edit]. On this page you have more information and examples about “ni suru” and the related expression “ni naru”: Becoming and Deciding: NI NARU and NI SURU (になる and にする) – Japanese MEOW Language School

The explanation of the grammar is correct but in this sentence it’s 買う which means buy (ie. I bought a cat). To keep a cat would be 猫を飼う

Yes, you’re absolutely right. I mixed up that pair of homophones. Thank you for the correction