I might be in a minority here, but I've found that question (more often a variant) is usually only asked to figure out whether or not you can offer support. I ask something similar myself because I don't want to go on about breastfeeding if you're formula feeding.
I like to find out because I breastfed, but had lots of problems with it. Things like tongue tie that are quite common, but new mums don't necessarily know about. I can offer support in this area (who to contact, what times clinics are at, what doctors I know of, which bf support groups are in their area, etc) which many women are grateful for. I offer to hold the baby or change a nappy, but wouldn't suggest I take the baby for a morning because I know the mum will need to be nearby to feed.
On the other hand, I don't know very much about formula feeding, so can't offer support on that. But if I know baby has formula, then I can offer to babysit for a morning without worrying that I need to stay near the mum.
I'm not judging, just trying to gauge if there's anything I can do for the new mum.
Asking this question has led to many long and detailed conversations with friends of friends, passing acquaintances and randomers about breastfeeding. Sometimes I've been able to offer practical support, but a lot of the time they just want to talk out loud and comfortably about things like full breasts, sore nipples, painful let down, nipple shields, breast pumps, blocked ducts, etc etc. Lots of women don't know anyone who breastfed and don't have anyone to talk to who isn't going to tell them to just stop and formula feed.