There are a number of different ways to think about consistency: external consistency (like to other products, or to platform conventions) and internal consistency. I think you're asking about internal consistency, so that's what I'll focus on here.
A central goal of designing interfaces is the expression of a coherent model. This is literally true, in the sense that software is built on a collection of abstractions that model the goals of the product. But it's also figuratively true for designers, as our job is to turn those abstractions into a crisp mental model for the user.
These aren't always the same. Take the typical volume slider as an example. The following is from iOS:
The software abstraction (I'm guessing) ties pixel position to a numerical value. However, the mental model offered by the interface presents the choice as a continuous band. This makes more sense to users as the human ear doesn't perceive volume in discrete steps. There's the volume level you want, and everything else is either too high or too low.
A good mental model is object-oriented. The user perceives the foundational "proper nouns" or "atoms" of the application, e.g. concepts like photo or song or like. Consistency plays a few parts here.
Consistent representation of these objects means the user recognizes them for what they are when encountered. Consider Twitter's developer display requirements
Without consistent representation, a user will struggle to understand what they are looking at ("Is this a tweet, or a user and their bio?") and they won't know what to expect out of object-tied actions like Favorite.
To be more nuanced, consistency across classes of objects, in combination with intentional contrast, is a critical tool. For example in a music application, albums and playlists probably should appear similarly in most cases (e.g. as a collection of songs), but the user should understand which one they are looking at.
Consistent behavior is also important. The available actions/verbs should obviously be consistent within a single object type (e.g. retweeting a tweet always works the same way) but they should also be consistent between objects of different types. For example, following a topic and following a user on Twitter is a very similar experience: they are both sources of new content for your home feed.
These principles create an environment where, over time, the user will be able to anticipate what will happen before they perform an action. Consistency becomes something like a promise that you make to the user ("whenever you see the color blue then you can assume every time that it's a link"). Further, they will be able to bring these expectations into new features or aspects of the product that they haven't explored, speeding up the learning curve.
A predictable system seeps into your subconscious to the point where you don't even notice it. You're in the zone, even if it's just for a few seconds at a time. Conversely, if you learn that you can't trust a system to make good on its promises then you'll always have a moment of cognitive pause which leads to stumbling, confusion, frustration.