It CAN provide up to 5A constant current. It can be run as either a voltage regulator or as a constant current source. It will not provide more current than it can be supplied with.
If you hook it up to a 30VDC 500mA supply, and you want to charge a battery, you need to hook it up as a constant current source that charges at a current less than 500mA. You will burn up quite a lot of power in the regulator. I would try for a AC/DC supply that is much closer to the voltage of the batteries you are charging.
LM338 gets hot because you are dissipating a lot of power in it. Hook it up as a CCS, limit the current to a low value, lower the DC input voltage, put a sink on it. Any of those will help.