Many thanks for your message and sharing videos and code.
This Idea is about Revit API functionality which is not same to the Revit UI. "ConnectTo" Method works fine to connect elements only when the connection points are at exact same position between the elements and when no other modification in geometry size or other parameter is necessary for the connection to work.
Question:
Could you please confirm if in your first video that the pipe and fitting element are at the correct location having their connection points at exact same position?
To verify that the "connectTo" method works:
1. Connect the vertical pipe to the fitting using the Revit UI.
2. Disconnect the Pipe from the Fitting using the Revit UI.
(Now that your elements are in the position having connection points at exact same location and elements do not need adjustment in their geometry and size and other parameters)
3. Try to use the "connectTo" method to connect pipe to fitting.
(This should work)