Science, technology, and innovation are becoming increasingly collaborative, prompting concerted efforts to understand and measure the factors influencing these collaborations. This study aims to explore the driving factors and underlying mechanisms of collaboration dynamics based on patent data. Multilayer longitudinal networks are constructed to scrutinize interactions among organizations as well as the embedding of their knowledge elements in the network fabric. We then analyze the structures and characteristics of collaboration and knowledge networks from global and local perspectives, in which process topological indicators and graphlets are used to feature each organization's collaborative patterns and knowledge stock. Knowledge elements are extracted to present the core concepts of patents, overcoming the limitations of predefined categorizations, such as IPC, when representing technological content and context. By performing a longitudinal analysis using a stochastic actor-oriented model, we integrate network structures, node characteristics, and different dimensions of proximity to model collaboration dynamics and reveal the driving factors behind them. An empirical study in the field of lithography finds that organizations with a larger number of partners or a higher number of annular graphlets in their collaboration networks are less likely to collaborate with others. If an assignee has a more extensive range of knowledge elements and demonstrates a higher capability for knowledge combination, or if its local knowledge network exhibits weaker connectivity, its propensity to seek new collaborators increases. Both cognitive and organizational proximity play important roles in fostering collaboration.