Mysterious basement drain pipe?
The pipe might be a cleanout for your drains or maybe the drain for an earlier fixture there. The black and red thing was a cap.  It has been broken or sawn off.  Just replace that cap with an identical one, or better, get an actual cleanout that fits the grey pipe and install that instead.  I'd avoid using a compression fitting like this especially in a basement.   There are situations where the basement drain can develop pressure behind it, and the cap then pops off.  Very unpleasant.  An actual cleanout looks like this