None of these were legal marriages. Of course anyone can stage whatever they want. This has always been legal even here in the US. The articles point out that no one actually held the emperor married to these men and just put it up to the emperor's eccentricity.
Moreover in the case of elagabalus, it's possible the stories were made up to discredit him and if they weren't made up they were highly scandalous and not at all well accepted. Forget marriage, even the insinuation he had slept with men was considered too scandalous to mention..
> Elagabalus had nothing at all to make up for his vices, which are of such a kind that it is too disgusting even to allude to them