Broadcom Ltd. agreed to buy Brocade Communications Systems Inc. for $5.5 billion, expanding beyond its main business in chips to add boxes that help connect storage systems to computers in data centers.

Broadcom, one of Silicon Valley’s most aggressive acquirers, said it plans to sell Brocade’s other communications technology businesses to avoid competing with companies that now buy Broadcom chips.

The...