Pakistan came back from behind to beat Australia 2-1 in an ODI series, their first in Australia in 22 years, in Mohd Rizwan's first captaincy series.