You don't. You write your backend code and vercel (and others) turn it into serverless functions that can be deployed on AWS or Cloudflare. Or whoever else decides to offer serverless functions. Or you extract your backend and host it yourself. You're not vendor locking yourself.
Haven't yet used their /api serveless functions but I guess it's standard nodejs functions, so not that much vendor lockin
You can deploy next.js application on any server which supports Node.js.