There is an option while booking - 'Book only if all berths are allocated in the same coach' - You need to select that option. Most probably, seats will be allocated in the same coach. If not, then tickets will not be booked, and IRCTC will tell that seats cannot be alloted in the same coach,