Probably because you were in a server that isn't designed to hold that kind of capacity. In general, though, lag is a common side effect of large crowds of people joining a server, and since it depends on a lot of different factors (first and foremost of which are the signal strength/ping grade of the host and of the joiners), it's not really a 'bug', nor is it truly fixable.