Public transport will be made free in two Australian states because of rising petrol shortages due to the Iran war.