Shortcode to do math with url variables

In your case, because you call [URLParam] twice, you need to store this data in session, because every call of your shortcode is isolated. If number of params is fixed (param1, param2 and operation, for example) better use it in single shortcode. Actually, there is a lot of variations, how to solve this.

You can use any conditions in shortcode params. For example

[math params="var1,var2,cond-sum"]

And, after extraction, convert it to var1 + var2.