It's not Coursera and EdX. It's that foreign students pay full price. As administrative costs increase and infrastructure costs increase and state contributions decrease if there ever were any, the money needs to come from somewhere.
Specific programs also tend to set their own prices. Even in Canada with all public schools tuition for business, medical, veterinary, etc. Are all higher