Borrowing hit £3.1bn last month, the highest level for July since 2021, official figures show.