Rav Perlow says that it is evident from this Gemara that just looking at the aron is not a capital offense (for anyone living after the dor hamidbar). Otherwise, its question, “Why did they deserve death?” would make no sense. Rav Perlow, therefore, suggests that the Rambam rules in accordance with this Gemara, as opposed to the Gemara in Yoma that implies that the prohibition applies to all generations (except for those who lived during the era of the first Beis HaMikdash).
Perhaps we can suggest that the Rishonim who include the prohibition as one of the 613 mitzvos do not agree with the Rambam that a mitzvah must be applicable for all generations in order to be included in the list. Or perhaps they rule in favor of the Gemara in Yoma that implies that the prohibition does apply to all generations.