Either one can be used BUT dumbbells have a slight advantage over barbells.
Dumbbells place a load on each side (this will indicate if one side is weaker than the other). Barbells won’t allow you to easily see imbalances because weight can be lifted without consideration of which (if any) side is weaker.
There are reasons to use both for bench work and reasons not to use barbells. In all situations with using an external load (especially barbells, dumbbellls, kettlebells, etc.), the use of caution, control, and proper progression is essential. I do not use bench press or shoulder press with clients in the traditional form. While many of my athletic clients perform these lifts as they are given importance in recruiting, I teach other integrative movements for the intended movements and muscle groups.
I do use dumbbells and barbells, but I doubt that many reading this use them in the same fashion that I do.