According to Apple, your iMac supports the following as second displays:
This model can simultaneously support the internal display at full native resolution and up to one 5120x2880 (5K) external display at 60 Hz with support for one billion colors; two 3840x2160 (4K UHD) external displays at 60 Hz with support for one billion colors; or two 4096x2304 (4K) external displays at 60 Hz with support for millions of colors. It supports both extended desktop (second workspace) and video mirroring (internal display duplicated on the external display) modes.
This means that only one 5K external monitor is supported. Two 4k monitors are supported however. I suspect this is due to the throughput of Thunderbolt, which is 40Gbps. A 5k monitor requires 28 Gbps alone. Also, you can not daisy chain the video connections, so you will need a thunderbolt dock with either displayport or HDMI port connectors for the monitors.
In response to questions below:
A Thunderbolt dock doesn't change the throughput of Thunderbolt or the Mac, it just adds additional connections. So, the dock will not allow two 5k monitors. It only provides additional connections. Now, perhaps your iMac already has two Thunderbolt/Displayport connections on the back to support the 4k monitors (not sure). If not, this is the role of the Thunderbolt dock, so you should purchase one with the needed connectors (they are all different so consider wisely).
An eGPU can drive your desired 5k monitors, but you will have to research the available eGPU options to find support for your configuration.
Note that the biggest limitation in this is the cable and connectors: Apple introduced 5K in iMac first, because Thunderbolt 2 only supported 20Gbps, which is not enough bandwidth for 5k, so they built the monitor into the system and created a sort of dual Thunderbolt 2 connection inside.
Thunderbolt 3 introduced 40Gbps, allowing 5k (Thunderbolt used mini-displayport connections and now usb-c style connections). Displayport connections (minidisplayport on Macs can support 5k with some displayport1 and all displayport2, which is on the Mac. For HDMI connections, HDMI 1.2 can support 1080p, with HDMI 1.4 needed for 4k. To get 5k, you need to have support for, and a cable that offers HDMI 2/2.1. Even then, most systems get 5k by compressing the signal.
So to get dual 5k on your system, you will need to use Thunderbolt to an external GPU, and then either Thunderbolt or HDMI 2.x from the eGPU to the Monitors, which means you need the proper monitors as well.