The painted line and the lights do not align for a very practical reason: it would be a major pain in the behind to paint over the lights, as each one of them would need to be masked for the painting, and have the masking removed afterwards.
Another reason, as pointed out in the comments by JScarry & Ralph J, is that placing the lights slightly to the side will keep the nosewheel from running over the lights. While the lights are designed to stand this, the constant thumping will put unnecessary strain on the landing gear, crew and the passengers.