You are doing nothing wrong here. The expression is correct. It just seems like, the attribute() as well as attributes() function does not work in print layout (at least in 3.16). I dont know why. I can only provide a rather poor workaround:
Instead of a textfield, add an attribute table and select your layer as datasource and remove the header as well as ...
You may set different labels for different scale ranges. E.g. pink labels for 1:1000 to 1:10000, red labels for 1:10001 to 1:25000.
You may set a scale dependent visibility for all of you labels. E.g. no labels are visibile above 1:25000.
I found out, that I missed the label-TAG with PropertyName: