Cat defecates randomly

The cat wets the bed, urinates on the sofa, defecates randomly, and urinates inappropriately.
Many cat owners would say:
My little cat usually looks so cute.
But today, it put on a “big disaster movie” for me again.
When I got home from work, goodness me!
It directly left me a “surprise” on the floor of the living room.
Am I raising a cat or inviting a “father who defecates and urinates anywhere he likes”?
How can I make it go to the litter box obediently?