Filtering artefacts and filtering short signals
All real-time filtering (as opposed to post processing) wirh FIR and IIR filters will have start up transitions based on the state of the filter at start up. For optimum rejection of AC noise , Instead of a Butterworth Filter consider using an 2nd order IIR notch filter with the notch set at your AC frequency (such as 50 Hz). A design for this is further explained on this site and is simple and effective for this purpose, and happens to be demonstrated with a notch at 50 Hz. (Transfer function of second order notch filter).
To have shorter segments, partition into segments at the output of the filter so that the filter’s memory can be maximized to meet the filtering requirement as designed (a filter’s transition bandwidth between passing a frequency of interest and rejection is dependent on the span of its memory—- for tight rejection long memory is required.)
If the application is for very short durations at completely different instances in time, that can make no use of the prior immediate time domain signal, then such traditional FIR and IIR filtering techniques will not be suitable beyond what they are capable of for the given time span. That said, the IIR nulling approach with its rejection optimized at the interference frequency may be sufficient and simple.