Studying the fundamentals is the honest starting point — computer science courses cover the maths, data structures and systems programming that engines are made of.
In practice, most people learn by taking engines apart first. Work through a public engine such as an open-source renderer, then try assembling the pieces yourself: a game loop, a rendering layer, input handling, physics and a scene or entity system. Each of those is a project in its own right.
Plenty of developers also skip writing an engine entirely and build on Unity or Unreal, which is a perfectly respectable route unless the engine itself is the thing you want to learn.