Has this phone been dropped, repaired (prior to you changing the battery) or came into contact with water recently? Likewise, have you been using a low-cost charging brick and cable?
The symptoms resemble those of a water damaged device. Don’t be fooled by the fact that the iPhone 7 is water resistant…it’s not always so. A cheap charger can also damage the charging circuit which would also give you similar symptoms.