Hello, Greetings of the day!
Section 34 of the indian penal code deals with common intention of several persons in furtherance of a pre-planned criminal act.Each of those persons are liable for the said act as it was done by a person alone. However for prosecution under this section,there must be more than 2 persons and less than 5 commiting the criminal act.
Section 149 deals with the offence committed by an unlawful assembly in prosecution of a common object. Every person who, at the time of the committing of that offence, is a member of the same assembly, is guilty of that offence. Section 149 deals with the 5 or more people as that would account for unlawful assembly here section 34 is not applicable.
Section 34 talks about common intention whereas section 149 talks about common object such as the common object has a wider scope.
Please refer to this link for more clarification:
Hope it helps