When using Connect Linework tool from the Topology Cleanup toolbox in a 3D model, the default elevation is 0.
Therefore, only lines on Z=0 will be considered for connecting.
To consider Z values set the following user preference:
Workspace > Preferences > Topology > Consider Z enabled.