An analytic treatment of magnetically deformed neutron stars