The addMonths (-1) will add or substract a month from your input date value. The EndOfCurrentMonth token is just your parameter/date time value. It's not specific logic that will check if it's the latest day of the month if you add/substract months. Maybe you want to go to previous month of this specific day (for example 8-3-2024), you should be able to substract a month as well. So, it does make sense.
You could solve it by doing addDays([%BeginOfCurrentMonth%], -1). This should always give you the latest day of the previous month.
In the function addMonths(Parameter 1, Parameter 2) Parameter 2 is the number of months to add or, in your case, subtract.
So in your example the "-1" means minus one month, and "-2" means minus 2 months.
I'd say the function is behaving as expected.