This is a difficult one to answer because it depends on numerous factors. The main factors are how often the vehicle is being used, how well it is charged, how well it is maintained, high temperatures and the application. Battery life has become shorter as energy requirements in modern vehicles have increased.
A battery prefers to be used regularly or regularly charged. Many modern vehicles have a constant drain even when the ignition is off which will flatten the battery and shorten the life if the vehicle is not being used regularly. Vehicles now days have a lot more electrical accessories fitted which puts added strain on the battery.
Another factor that is becoming more important is locking your car. Modern vehicles, especially luxury cars have many computers and accessories still running when the key is removed, they don’t go to “sleep” until the car is locked. So even if your car is in a locked garage it is good practice to lock your car to improve battery life.