What is the purpose of cylinder "second power bricks" on cords?
It's a ferrite choke. It's ring of ferrite that the cable runs through. Think of it as a one-turn inductor where the core materials is lossy at high frequency so high frequencies energy get dissipated as heat. You can buy them separately as rings of ferrite and actually wind more than one turn of the cable through them, if you wish. Or as clamshells that clamp around the cable.

It is there to stop the cable from becoming an antenna that radiates or picks up noise, and suppresses external noise from entering the system through the cable, and keeps noise in the system from exiting the system through the cable.