Translation:The horse is standing next to the elephants.
How would you say "The horse stands next to the elephant?" "...neben dem Elefant?"
That's what would make sense. But actually it's "...neben dem Elefanten."
"Elefant" is one of a few German nouns that get the "en" added even to the singular form of the word (elephant), in every case except nominative case. That is, unless "the elephant" is the subject of the sentence (nominative case), it's always "Elefanten", even when it's singular.
And I think you've already correctly figured out that you can tell which way it is (singular or plural) by the form of "the". In the example sentence, the elephant is in dative case. "den" is the form of "the" used with plurals in the dative case, so it's actually "elephants". If it were just one elephant, then it would be "dem", just like you thought (except it would still have an "en" ending because "Elefant" is weird that way).
See the various forms of Elefant for the different cases for both singular and plural here...
Thank you. Is there any way to know what words have a "strange" ending? Does it have anything to do with the word's origin, or are they just exceptions?
Honestly, I don't know. I think mostly they are just exceptions, but nouns that behave the way Elefant does here are always masculine, and usually pertain to living things. In school, we were told these were called "masculine N-nouns" or "weak nouns". Unfortunately, I have not been able to find an exhaustive list of these, but here are a couple of web pages that may be helpful.
Actually, canoonet DOES have exhaustive lists of examples for every noun declension class it defines. They are in the grammar section I believe.
Neben can go with dative or it can go with akkusativ, How do we know what to use?
If the verb refers to movement, then you use Akk: Ich gehe in die Küche. (you ask the question 'wohin'=where to)
If the verb indicates location, you use Dativ: Ich bin in der Küche. (you ask the question 'wo'=where). You also use Dative when you refer to time: Sie kam in der Nacht.