Both idioms ''to cling to'' and ''to be attached to'' can be used either literally or figuratively:
1) ''cling to'' --> when used literally, it means ''to hold on to someone or something tightly.''
E.g.: ''The little girl clung to her dad's legs and cried as he tried to leave for work.''
E.g.: ''I clung to the side of the rock and prayed that a search party would find me.''
--> when used in a figurative manner, it describes the act of remaining devoted to something (often a belief or opinon) or thoughtful of someone's memory.
E.g.: ''In this ever-changing world, you can't just stubbornly cling to your old beliefs.''
E.g.: ''He can't be bothered to cling to the memory of his unfaithful wife.''
2) ''be attached to'' --> when used literally, it means ''to be connected to someone or something.''
E.g.: ''Please, be sure to attach yourself to your luggage at the airport.''
E.g.: ''As she was fussing with my sweater I asked her to attach that small button to it.''
--> when used figuratively, it means to involve oneself with another person or group - often in an overbearing way.
E.g.: ''I hope my little cousins don't try to come with us—they're always attaching themselves to me, and it's so annoying.''
--> In a figurative way, it can also be used when you want to state that you are fond of someone or something.
E.g.: ''My dad is really attached to his old-fashioned ideas.''
E.g.: ''She seems to be really attached to her new boyfriend.''
Hope that helps!!! :)
Please do not hesitate to contact me should you have any further questions. I shall be pleased to help.