Ran into an issue trying to replace a light switch with a Lutron dimmer switch. There are three switches for the light. As you can see from the photo, I have 5 wires into the current switch. I only have 4 wires on the Lutron (Red, Black, Red, Green).
What you're looking at there is a 3-way switch. It's not a 4-way even though it has 4 wires.
Black screw is common, brass screws are travelers.
What's happening there is that the switch has both side screws and backstabs. Each backstab is electrically connected (continuous) with the nearest side screw. And so, the installer is using this feature to also splice the two black wires to each other.
This very strongly suggests the 2 black wires are "supply always-hot" - one from supply and the other taking it onward to other switches or points of use elsewhere. It might be something else, but that's probably irrelevant to the switch wiring.
Yes, I know there's a third black, but I'm a huge fan of using colored electrical tape to identify wires by function - like this.
Now you know what the wires are doing, you'll need to connect the Lutron dimmer according to its instructions. It goes without saying that you need a dimmer capable of working in a 3-way circuit, but from the wire colors you describe, this is likely the case.