The two black wires at the top are the hot from the panel and the hot continuing to the other loads. They are connected together inside the existing switch. The black at the bottom is the switched hot to the lights.
You need to connect together the top two wires and connect those to one side of the dimmer. The bottom black needs to be connected to the other terminal of the dimmer. The bare wire is ground and goes to the green screw or wire on the dimmer.
Assuming the dimmer has built-in wires, use a wirenut to connect the two hot wires to one of the dimmer wires. If it has screw terminals, add a short piece of wire (pigtail) between the first terminal and the wirenut and two hot wires. Do not try to put two wires under a screw; this will not make a reliable connection.
Also, if your dimmer needs a neutral wire, you’ll need to tap into the bundle of white wires. Don’t separate the whites but add a wire to the bundle. You may need a larger wirenut. Also, don’t use the ground wire as a neutral; it will probably work but can be very dangerous.
Edit based on new photos:
I was able to identify the dimmer from your photos and found the installation instructions here. You tried to wire the dimmer as a three-way switch but you need it as a single-pole switch. You must not use the YL terminal on the far side from the BL terminal; only use the BL terminal and the YL terminal next to it.
You need to connect the two wires originally connected at the top of the switch to the black terminal using a pigtail (short piece of wire) to a wirenut. The black wire originally connected to the bottom terminal of the switch connects to the single YL terminal.
Now I'm going to assume you've lost track of which wire is which at this point. Normally, I'd discourage experimentation with house wiring as dangerous but in this case, using only these three wires, it is safe, With the breaker turned off, wirenut together two black wires with a pigtail to the BL screw and connect the other black wire to the YL screw. Turn the breaker back on and see what happens. If everything works correctly, turn off the breaker, tuck the dimmer back in and turn the breaker back on; you're done. If the main light is always on or all lights are dimmed, turn the breaker back off and switch wires. Continue until you get the correct combination.