Usually, UN and EU are written without periods, for some reason that eludes me, while U.S. almost always is written with periods. It's just the convention that evolved. I'm not sure there is any rhyme or reason to it. I don't think it would be incorrect to put periods after U.N., but one doesn't usually see it written that way.
Maybe U.S. has them because, without them, someone might