Hello Rosan13,
As with all unexpected iPhone behavior, try taking the following steps which may help with this: restart your iPhone, close the affected app (Phone app) then reopen it, and make sure all apps are updated.
Restart your iPhone
“1. Press and hold either volume button and the side button until the power-off slider appears.
2. Drag the slider, then wait 30 seconds for your device to turn off. If your device is frozen or unresponsive, force restart your device.
3. To turn your device back on, press and hold the side button (on the right side of your iPhone) until you see the Apple logo."
Close an app on your iPhone or iPod touch
“1. From the Home Screen, swipe up from the bottom of the screen and pause in the middle of the screen.
2. Swipe right or left to find the app that you want to close.
3. Swipe up on the app's preview to close the app."
How to manually update apps on your Apple device
“1. Open the App Store.
2. Tap your profile icon at the top of the screen.
3. Scroll to see pending updates and release notes. Tap Update next to an app to update only that app, or tap Update All."
In addition, we'd suggest removing any cases and screen protectors you may be using on your iPhone during the testing period, in case one of those is pressing on the display and causing the speakerphone button to activate. It may be also worthwhile to test if this occurs on just calls or also FaceTime conversations.
We hope this helps. Let us know if we can assist with anything else at all. Take care.