Mastering case and gender agreement in fluent speech is an immensely tough nut to crack, so to anyone learning German as L2: Kudos; nicht aufgeben!
Two patterns overlap here (I was tempted to write "conspire against the unsuspecting learner", however language evolution is hardly ever deliberate or purposeful):
Strong vs Weak Adjective Declension
David's answer illustrates that difference very well. Nothing to add!
Washed-out Case Markers
While German articles, nouns, and adjectives have conserved case declension, the clarity of case markings has eroded over time. This led to, for instance, only six semantically distinct definite article words covering sixteen functionally distinct case-number-gender roles (four cases times three singular and one collective plural gender). In that effort they're supported - well, sort of - by far too few semantically distinct noun endings like -r, -s, -m, and -n, so that one way or another the combination of article variant and inflected noun does provide just enough information to deduct case and thereby, sentence function.
As if this wasn't complicated enough, the distinction between weak adjective inflection with, and strong adjective inflection without determiner only adds to the conundrum. This is why your assumption that a series of -m endings should consistently indicate a dative case ('einem anderem', theoretically) is perfectly logical, yet unfortunately not correct.
I am being deliberately judgmental:
For one, German's close cousin Dutch has done away with cases except in the context of a few fixed idioms and formulae. The same is true of other Germanic languages other than Icelandic. Russian on the other hand manages well with six (!) cases, but those are identifiable by much clearer markings and not confused by articles; presumably that is similar in other Slavic languages.
For another, I pick up on quite a few article-adjective-noun case agreement errors in the German online press, where authors may not have the luxury of getting content proofread prior to publication, and these things escape easily (no blame).
As multilingual user experience designer I am a stickler for form supporting function across all human artefacts, and comparatively, the German language simply does not do a particularly 'user friendly' job in that regard. My sympathies!