Collaboration plays a crucial role in STEM education. This study aimed to investigate the neural mechanisms underlying the benefits of collaborative behaviors using fNIRS hyperscanning. The prefrontal cortex (PFC) and right temporoparietal junction (r-TPJ) were targeted as regions of interest. Three key findings emerged from the analysis. First, IBS in the r-TPJ increased during the initial phases of collaboration, while IBS in the PFC increased during the later phases. Second, the frequency of scaffolding and questioning behaviors exhibited a significant positive correlation with the enhancement of IBS in the r-TPJ. Furthermore, the frequency of scaffolding behavior during the initial phases significantly correlated with task outcomes' fluency, integration, and technology scores. Overall, this study sheds light on the impact of different collaborative behaviors on IBS in different brain regions and task performance and proposes a new perspective on learning science using the brain-scanning method of fNIRS hyperscanning.