OK 2 separate things here, let me address the second forst. Yes the range of gravity is infinite, but it only supplies so much force. Since the Universe is expanding at such a high rate, it will conti8nue to expand faster than the force of gravity will slow it down.
No the first part; dark energy....who knows. No one knows at all what it is, there are a number of possibilities. Any electromagnetic effect would not be one of the possible explanations.
What has been found over about the last 5 or 10 years, is that the rate of expansion of the Universe is now speeding up, and has been doing so for about the past 5 billion years. Since there is no explanation, it is given the temporary name "dark energy" which means "a force that is causing the rate of expansion of the Universe to speed up that we don't know what it is". We just have the observations showing this effect which does not fit any form of gravity and normal physics. So it has this temporary name.