"El gato duerme cerca del perro."
Translation:The cat sleeps near the dog.
Yes, but the object language is Spanish and not English. Literal translations often look odd in the target language. I like to make a rough literal translation just to make sure I have the original meaning correct and then refine the translation to accomodate the target language's sensibilities.
because 'cerca' is an adverb. 'cerca de is a preposition. A preposition requires an object. An adverb does not. In our sentence 'the dog' is the object of the preposition 'cerca de'. If you want to use the adverb 'cerca' you can say 'el gato and el perro está cerca. The dog and the cat are nearby.