There are two types of books for D&D: rulebooks, and modules. Rulebooks like Player’s Handbook, Dungeon Master’s Guide, and Monster Manual basically are the game; without at least the core rules, you have to make up how everything works yourself and you’re not really playing “Dungeons & Dragons” per se. (Instead, you’re playing in a homebrew RPG system, or playing freeform, that is, without rules. Both are entirely valid and we take questions about these activities, but if you call them “Dungeons & Dragons” people will get confused.)
There are core rulebooks (e.g. Player’s Handbook, Dungeon Master’s Guide, and Monster Manual) and supplements (e.g. Tasha’s Cauldron of Everything). The core books are usually the bare minimum; supplements are optional. (It is possible to play without the Dungeon Master’s Guide or Monster Manual, but it can be hard, especially if you are new.)
The other books, modules, contain premade adventures like Tyranny of Dragons or Curse of Strahd. You need them to play those adventures, but you don’t need to play those adventures. You can make up your own adventure, even your own world, and just play with the rulebooks. That is definitely still D&D—in fact, traditionally, it’s the default and norm.
Even if you do run one of those adventures, they will encourage you to—and in practice, you will have to—customize them for your group. It is very rare—and almost never a good idea—to run an adventure exactly as printed, and even the adventures themselves will tell you so.