Flight paths appear curved due to the flat map (mercator projection), but are actually not quite as curved in reality. This is known as a “great circle” path.
Try it for yourself by finding a physical globe (spherical) and trying to stretch a piece of string between those two distances. You’ll find that the string seeks to the shortest distance, which will cross over roughly the same locations that the “curved” path took.
There are generally some slight deviations from the perfect “great circle” path, but those are usually due to weather or jetstream conditions dictating more efficient routes. Transoceanic flights will also sometimes try to remain as close to a shore as possible minimize the amount of time they have to be over water should an emergency occur, but most of the curvature is still due to great circle projection issue.