ーI planted some flowers in my garden to stop the weeds from coming in.
「雑草対策に庭に花を植えた」
to plant some flowers で「花をいくつか植える」
to stop the weeds from coming in で「雑草が生えてくるのを止める」=「雑草対策に」
ーI planted some flowers in the flower bed in front of my house hoping not as many weeds would grow there.
「雑草対策に家の前の花壇に花を植えた」
flower bed で「花壇」
to hope not as many weeds would grow ...で「たくさんの雑草が生えないことを願う」=「雑草対策に」とも表現できます。
ご参考まで!