I had similar problem with Massey Ferguson 165. Solenoid would click but not engage the starter. You may have to try numerous times before it would engage the starter to turn the engine. The problem is that there is not enough power going through the solenoid to engage starter. The solution is to wire a relay into the starter circuit. It’s not that difficult. It’s an known design problem which appears on older tractors/diesel engines. Here’s a link to it on another forum reply #18.
https://www.tractorbynet.com/forums/kubota-owning-operating/42640-b2400-starting-problem-finally-solved-5.html
I bought a generic relay and wired it myself. see link for part on amazon.
https://www.amazon.co.uk/gp/product/B07XDRNZ7M/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1
Red to power line into starter(30), Black to earth (85), white (86) to ignition switch and blue(87) to original cable on ignition switch to solenoid.
I had spare spade on the power line from the starter on the ignition switch so I wired power from there. The white and blue cables go between ignition switch and existing solenoid cable.
Starter engages first time now without any issues