Max doesn't walk around aimlessly, say inappropriate things, and do dangerous things because he's not smart, he does them because he has a short attention span and acts on impulse (see the lyrics to
World of Max).
The way I saw the ending wasn't that Max came in from an alternate timeline (Sam did refer to him as "past Max" not "alternate reality Max"), but that he was having a similar adventure somewhere else with past Sam (like how Flint Paper said he was having a very similar adventure to Sam & Max during Season One). The way I saw it, the Sam & Max we were following were paradoxes (because when the past Sam & Max stole the time machine they had to complete the events of Situation Comedy completely different since they didn't have the recording contract). The past Sam & Max continued on, changing things, making the Sam & Max we were following become out of sync with the timeline. When past Sam was killed after he became a giant monster, past Max took the time booth (which he could still have, since the events of Season Two would be completely different, and because they were different he could still have the card programmer. So, he could have scanned anyone from Season Three to get to Sam's present place in time - even possibly Sam himself, because it's not known whether the past Sam & Max ever scanned past Sam and whether the scan would lead to the same place in time since the events were different).
Since Max acts on impulse, it would make sense that since past Max still has the time machine, he'd have been randomly scanning people during his adventures with past Sam and that he'd use those cards to travel around aimlessly after past Sam died. It's likely that the machine taking him to Sam was completely unknown to him since Max looked surprised at the machine taking him to Sam as well.
And, as for the two Sams and two Maxes in one universe paradox, I look at it like Bender's Big Game. One Max was killed and one Sam was killed, now there's only one Sam and only one Max, as it should be. So, the universe corrected itself.