Anthony Albanese has struck an 11th-hour deal with the states and territories, securing public hospital funding for the next five years.