How to change the label of title field
You can change the title label by editing the node type settings by going to Admin > Content Types > (type) > Edit. No code needed, and this can be exported to configuration.

I’m not even sure what your code is trying to do, but you don’t need it.