Square announced an agreement on Thursday to buy website-building company Weebly for $365 million. The deal is expected to close in the second quarter of 2018.