You are assigning the current date to
$data['month']
In your check to see if 'month' were posted, you assign
$data['month'] again to the new value of what was posted. I presume from the info you gave that the returned GET was for 01-2023?
This returned January and a month in arrears as December, which is correct, so I am not too sure where your problem lies.
Matter of fact, months like February or months with 31 days might return an error or the incorrect month or show your month in arrears as the same month. To overcome this, use the following to prevent the "last days of month"-error. Just use a second strtotime() to set the date to the first day of the month -
echo $newdate = date("m-Y", strtotime("-1 months", strtotime(date("Y-m")."-01")));