two-year-old 作为一个连词整体,相当于一个形容词的作用,而two years old是不可以直接做定语的,这样可以:
I have a cat of two years old at home.