Stats are influenced by base stats, EVs, IVs, and nature. Riolu has a much higher base stat in Attack than Special Attack (70 vs 35), so that is probably why its Attack is higher. Lucario has roughly equal base stats in Attack and Special Attack (110 and 115), so its stats should be similar after evolution.