Amazon has entered a surprise bid to buy TikTok as the app faces a U.S. ban unless it separates from its Chinese owner.