One must light Shabbat candles before sunset. If one has still not lit Shabbat candles after sunset, one cannot light them at that point, because after sunset it is bein hashmashot, the time period in which we assume Shabbat has possibly entered. Therefore, doing something de'oraita (Torah-level), like lighting a fire, would be asur (forbidden).
We therefore typically light candles in our parts about 18 to 20 minutes before sunset. In places like Yerushalayim, they light 40 minutes before sunset. However, one can light Shabbat candles as early as plag hamincha, which is an hour and a quarter seasonal hours prior to sunset.
But there is a difference between when a person lights around plag hamincha, that early, and when they light closer to sunset. If a person is lighting closer to sunset at the recommended time, they do not have to accept Shabbat right away with the lighting of the candles. The lighting of the candles is still assumed to be for the purposes of Shabbat because the person is lighting so close to the start. However, if a person is lighting very early, like at the time of plag hamincha, they would have to accept Shabbat with the lighting of the candles. Otherwise, it is not clear that the person is lighting the candles for the purposes of Shabbat, because it is very early in the day.
This becomes very relevant in the summertime, when sunset is very late and people want to take Shabbat really early. They ask, “What’s the earliest candle-lighting I can have?” They will usually get the time for plag hamincha and light at that point. They must be careful that, even if they are in other parts of the year, they do not accept Shabbat automatically when lighting candles. If they are lighting that early, they must accept Shabbat with the lighting of the candles, in order to make it obvious that the lighting of the candles was for the purposes of Shabbat. Therefore, they would not be able to do melacha (prohibited labor) or anything else after that.
Have a great day.

