As someone who started to study economics and switched into computer science, can anyone explain why Stata is used for most economics work when Python/Julia/R seem like such better options and are free?
Your question implies a limited view of the field of economics. Stata is the dominant piece of software in fields like labor economics. That's because the people working in those areas want to enter a few commands or click a few menu options and let Stata do its thing. It's hard to beat for that type of analysis. Just make sure you don't want to do any actual programming.
Macro theory traditionally used Matlab and Fortran. Time series long ago used GAUSS, RATS, and EViews, among others, but never Stata. R and Python are used a lot today. Then there are others like SAS and LIMDEP that are no longer used as much, but have their niches.