Machine Learning-Driven Process Analysis and Optimization in Solid-State Welding and Fusion-Based Additive Manufacturing