One of the two non hot black wires is the light feed and the other is a feed to other loads possibly some receptacles but it doesnt matter. A three way switch is different.
Dimmer Switch
Wiring a dimmer switch with red and black wires. The wires from the dimmer will typically be black. Turn the power back on and turn the switch on. Tighten a wire nut over each pair of wire ends. The other outlet powered by the black wire which always has power is always on. Fold the wires neatly into the box. In the split tab configuration the two halves of the outlet are separated and the red wire goes to a wall switch.
The switch it is connected to is a dimmer switch with an onoff button as well as a dimmer slider. Screw the dimmer to the box with the screws provided. Finish the job by installing the cover plate and turning on the power to test the new dimmer. This type of switch lets you turn the light off or on from more than one place in the room. These wires attach to the travelers which are the pair of wires attached to the two screws at one end of the regular 3 way switch. Connect each dimmer wire to a house wire by gripping the wire ends with a pair of pliers and twisting them together.
Connect either of the other two black wires to the other screw on the switch. The two house wires may be black red or white with black marking. You have a 2 way switch. When you see a red wire in an outlet box its usually because the outlet is a switched outlet. Attach to the wire commonly found on the screw by itself on the regular 3 way switch typically the power or the switch leg leaving to the fixtures. It doesnt matter if you reverse the two switch wires to a single pole dimmer.
The wiring in the ceiling contains a black red and white wire as well as a ground. If it doesnt work switch the lower wires. One of the black wires is probably the line and the other carries power to some other device on the circuit. The red wire is probably the load its also possible the red is the line and you have two loads controlled by the switch. The fixture contains only black and white. This is a typical wiring setup for a 3 way light switch with black white red and ground wires.
They are connected together by one using the backstab connector and the other the screw. This simple diagram below will give you a better understanding of what this circuit is accomplishing. With the power off connect the black hot wire to the old switch. Black wire power or hot wire white wire neutral bare copper ground when wiring a dimmer switch circuit all we want to do is to control the black wire hot wire to turn dimbrighten the load.