In some cases, it’s perfectly fine to mix and match shoes if they don’t drastically impact your inseam measurement. Wearing two sets of sneakers with the same jeans, for example, would probably be fine.
However, it isn’t recommended to wear the same pants with heels and flats unless the pants are meant to stop at the ankle. Skinny jeans and boyfriend jeans can both look great with heels and flats since they stay cut off or bunched up at ankle height.
Jeans or pants that extend beyond that point wouldn’t be appropriate for both types of shoes. Heels require a longer inseam to offset the height difference, so wearing flats with the same pair of denim would only cause the hem to drag on the floor and pose a tripping risk. Similarly, wearing heels with pants tailored for flats would make your pants appear mismatched and too short.