Yes, it's legal ... meaning that they won't arrest you.
But ... If you're a Prime member, you can bet that Amazon will quickly shut down your account once they see you shipping to an abnormal number of different addresses. Here's Amazon's Prime Membership terms page. Note the bullet point Note the bullet point under Other Limitations ... Prime members are not permitted to purchase products for the purpose of resale, rental, or to ship to their customers or potential customers using Prime benefits.
If you're not a Prime Member and you're willing to qualify/pay for each order's shipping charges, then Amazon probably won't care if you "drop-ship" to your customers.
In case you still wonder, Amazon dropshipping is a legit business model and people are still making money from it.