The songwriter and burgeoning pop star pivoted from crafting radio hits for Britney Spears and Camila Cabello to hitting out on his own.