Think of your database like a kitchen full of ingredients.
An API is the drive-through window in front of it.
You don't walk into the kitchen
You don't grab ingredients yourself
You just order, and the kitchen figures out the rest
That's why developers build APIs: so everyone else can get data without understanding how the sausage (or database query) gets made.