I re-examine the relation between virial mass and concentration for groups and clusters of galaxies as measured in a number of recent works. As previously noted by several authors, low-mass clusters and groups of galaxies display systematically larger concentrations than simple prescriptions based on pure N-body simulations would predict. This implies an observed concentration–mass relation with a substantially larger slope/normalization than expected from theoretical investigations. Additionally, this conclusion seems to be quite independent of selection effects, holding for both lensing based and X-ray based cluster samples. In order to shed new light on this issue I employ a simple spherical halo model containing, in addition to dark matter, also stars and hot diffuse gas in proportions and with distributions in agreement with the most recent observations. Moreover, I include the contraction effect experienced by dark matter due to the cooling of baryons in the very central part of the structure itself. The resulting modified concentration–mass relation is steeper than the theoretical input one, because star formation is fractionally more efficient in low-mass objects. However, the effect is non-vanishing at all masses, thus resulting also in a larger normalization. Overall the new relation provides a better representation of the observed one for almost all catalogues considered in this work, although the specific details depend quite significantly on the baryon fraction prescription adopted. Specifically, the observed concentration–mass relation seems to favour a scenario where the stellar mass fraction in large clusters of galaxies is substantially lower than several works have found. Anyhow, the same effect could also be produced by a redistribution of baryons within the structure. Moreover, the concentration of a number of high-mass objects seems to be significantly lower even than the predictions based on pure N-body simulations, and they are hence unaccounted for in the modified scenario that is proposed here. Finally I use this simple model to show how the estimated concentration of cosmic structures is expected to be overestimated as a function of the radial range covered by the analysis.