zhī (只) has similar meaning with jiù (就) in terms of the limiting of the number. They are hence semantically compatible. Therefore, the sentence "怎麼就只來了三個人?" is acceptable.
c´ai (才) has additional meaning of counter expectation. It is semantically incompatible with zhī (只) . Therefore, the sentence "怎麼才只來了三個人" is unacceptable.